package cn.melonlib.cores.jpa.model.bean.impl;

import cn.melonlib.cores.commons.comp.enums.OrderByType;
import cn.melonlib.cores.commons.comp.enums.QueryType;
import cn.melonlib.cores.jpa.model.bean.PaginationQuery;
import cn.melonlib.cores.jpa.model.bean.collections.JsonMap;
import org.intellij.lang.annotations.Language;

import java.io.Serializable;
import java.util.List;

public class PaginationQueryImpl extends DefaultQuery implements PaginationQuery {

    private final long page;

    private final long size;

    public PaginationQueryImpl(@Language("SQL") String content, List<? extends Serializable> params, long page , long size) {
        this(content, params,page,size,QueryType.HIBERNATE_QL);
    }

    public PaginationQueryImpl(@Language("SQL") String content, List<? extends Serializable> params, long page , long size, JsonMap<OrderByType> orderBy, QueryType queryType) {
        super(content, params,orderBy, queryType);
        this.page=page;
        this.size=size;
    }
    public PaginationQueryImpl(@Language("SQL") String content, List<? extends Serializable> params, long page , long size, QueryType queryType) {
        this(content, params,page,size, JsonMap.<OrderByType>createMap().append("id", OrderByType.ASC), queryType);
    }

    @Override
    public long getPage() {
        return page;
    }

    @Override
    public long getLimit() {
        return size;
    }

}
